<script>
  // 统计出现最多的字符
  function mostLetter(str) {
    let charMap = {};
    let maxNum = 0;
    let maxChar = "";
    for (let char of str) {
      charMap[char] = charMap[char] + 1 || 1;
      console.log(charMap[char]);
    }
    console.log(charMap);
    for (let char in charMap) {
      // console.log(charMap[char]);
      if (charMap[char] > maxNum) {
        maxNum = charMap[char];
        maxChar = char;
      }
    }
    return maxChar;
  }

  let str = "my name is aaaabaiseedeg";
  console.log(mostLetter(str));

  //   实现快速排序
  function quickSort(arr) {
    if (arr.length <= 1) {
      return arr;
    }

    let pivotIndex = Math.floor(arr.length / 2);
    let pivot = arr.splice(pivotIndex, 1)[0];
    console.log(pivot);
    let left = [];
    let right = [];
    for (let i = 0; i < arr.length; i++) {
      if (arr[i] < pivot) {
        left.push(arr[i]);
      } else {
        right.push(arr[i]);
      }
    }
    return quickSort(left).concat([pivot], quickSort(right));
  }

  let newArr = [1, 24, 23, 0, 23, 878, 33, 87, 93, 134];
  let data = quickSort(newArr);
  console.log(data);
</script>
